# -*- coding: UTF-8 -*- #
"""
-------真正的勇士， 敢于直面惨淡的Warning、 敢于正视淋漓的Error-----
@author : 贾鹏博
@file : goods.py
@time : 2022/6/29 21:27
"""
import requests
from apitest.电子商城接口框架.domain.goods_domain import GoodsDomain
from apitest.电子商城接口框架.apis.base_api import BaseApi


class Goods(BaseApi, GoodsDomain):

    def create(self, goods_data):
        url = "admin/goods/create"
        r = self.send("post", url, json=goods_data)
        return r

    def list(self, goods_name, order="desc", sort="add_time"):
        # 自己编写的接口对应的方法，应该和接口本身的逻辑一致
        goodsId_url = "admin/goods/list"
        goodsId_data = {"name": goods_name, "order": order, "sort": sort}
        goodsId_r = self.send("get", goodsId_url, params=goodsId_data)
        return goodsId_r

    def detail(self, goodsId):
        productId_url = "admin/goods/detail"
        productId_r = self.send("get", productId_url, params={"id": goodsId})
        return productId_r

    def delete(self, goodsId):
        url = "admin/goods/delete"
        r = self.send("post", url, json={"id": goodsId})
        return r
